package com.qf.hospital.system.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.hospital.system.entity.Pharmacy;
import com.qf.hospital.system.mapper.PharmacyMapper;
import com.qf.hospital.system.service.PharmacyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PharmacyServiceImpl implements PharmacyService {

    @Autowired
    private PharmacyMapper pharmacyMapper;

    @Override
    public PageInfo<Pharmacy> findByPharmacyName(String pharmacyName, Integer page, Integer limit) {
        //1. page
        PageHelper.startPage(page,limit);
        //2. select
        List<Pharmacy> list = pharmacyMapper.findByPharmacyName(pharmacyName);
        //3. feng
        PageInfo<Pharmacy> pageInfo = new PageInfo<>(list);
        //4. return
        return pageInfo;
    }

    @Override
    public int decrementByPharmacyName(Integer num, String name) {
        return pharmacyMapper.updateNumByName(num,name);
    }

    @Override
    public void incremntByPharmacyName(String durgName, Integer durgNum) {
        pharmacyMapper.updateAddNumByName(durgNum,durgName);
    }
}
